package com.bwie.controller;

import com.bwie.pojo.TProd;
import com.bwie.service.TProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.crypto.paddings.TBCPadding;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.sound.sampled.Port;

/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/4/24 13:59 59
 */
@RestController
@RequestMapping("/prod/index")
public class IndexController {
    @Autowired
    TProdService tProdService;

    @ApiOperation("商品列表")
    @PostMapping("getProdList")
    public R getProdList(@RequestBody PageInfoVo pageInfoVo){
        return tProdService.getProdList(pageInfoVo);
    }

    @ApiOperation("添加商品")
    @PostMapping("/addProd")
    public R addProd(@RequestBody TProd tProd){
        return tProdService.addProd(tProd);
    }

    @ApiOperation("获取字典表数据")
    @PostMapping("/getDictList/{typeId}")
    public R getDictList(@PathVariable(name = "typeId") Integer typeId){
        return tProdService.getDictList(typeId);
    }

    @ApiOperation("删除商品")
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable(name = "prodId")Integer prodId){
        return tProdService.deleteProd(prodId);
    }

    @ApiOperation("修改商品")
    @PostMapping("updateProd")
    public R updateProd(@RequestBody TProd tProd){
        return tProdService.updateProd(tProd);
    }
    @ApiOperation("kafk发送消息")
    @PostMapping("/sendMessage/{msg}")
    public R sendMessage(@PathVariable("msg")String msg){
        return tProdService.sendMessage(msg);
    }


    @ApiOperation("审核商品")
    @PostMapping("/changeProdStatus")
    public R changeProdStatus(@RequestBody TProd tProd){
        return tProdService.changeProdStatus(tProd);
    }
}
